var e = getApp(), t = require("../../339469457B99569C55F201426D89DBD0.js"), o = require("../../38034BA77B99569C5E6523A090A9DBD0.js"), a = t.getImgCheckurl(), s = t.getPhysiognomyUrl();

Page({
    data: {
        motto: "面相分析",
        images: {},
        info: "",
        icrName: "",
        score: "",
        userInfo: {},
        backUserInfo: {},
        hasUserInfo: !1,
        openId: "",
        nickName: "",
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        baikeUrl: "",
        imageUrl: "",
        description: "",
        remark: "",
        physiognomy: null,
        token: null
    },
    onShareAppMessage: function() {
        return {
            title: "AI面相分析",
            path: "/pages/physiognomy/physiognomy",
            imageUrl: "../../image/share.jpg",
            success: function(e) {
                "shareAppMessage:ok" == e.errMsg && wx.showToast({
                    title: "分享成功",
                    icon: "success",
                    duration: 500
                });
            },
            fail: function(e) {
                "shareAppMessage:fail cancel" == e.errMsg && wx.showToast({
                    title: "分享取消",
                    icon: "loading",
                    duration: 500
                });
            }
        };
    },
    bindViewTap: function() {
        wx.navigateTo({
            url: "../logs/logs"
        });
    },
    uploads: function() {
        var e = this;
        wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                e.setData({
                    img: t.tempFilePaths[0],
                    info: "",
                    icrName: "",
                    score: "",
                    baikeUrl: "",
                    imageUrl: "",
                    description: "",
                    physiognomy: null
                }), setTimeout(function() {
                    wx.showLoading({
                        title: "努力分析中...",
                        mask: !0
                    });
                }, 500), wx.uploadFile({
                    url: a,
                    filePath: t.tempFilePaths[0],
                    header: {
                        "content-type": "multipart/form-data"
                    },
                    name: "file",
                    formData: {
                        code: "XSYD"
                    },
                    success: function(o) {
                        var a = JSON.parse(o.data);
                        "0" == a.errcode ? wx.uploadFile({
                            url: s,
                            filePath: t.tempFilePaths[0],
                            header: {
                                "content-type": "multipart/form-data"
                            },
                            name: "file",
                            formData: {
                                openId: e.data.openId
                            },
                            success: function(t) {
                                console.log(t), wx.hideLoading();
                                var o = t.data, a = JSON.parse(o);
                                0 == a.recognitionResult.status ? (e.setData({
                                    physiognomy: a.recognitionResult
                                }), console.log(e.data.physiognomy.length)) : 1 == a.recognitionResult.status ? e.setData({
                                    info: "未检测到人脸"
                                }) : 2 == a.recognitionResult.status ? e.setData({
                                    info: "请上传单人照片"
                                }) : 3 == a.recognitionResult.status ? e.setData({
                                    info: "人脸不完整"
                                }) : e.setData({
                                    info: "Sorry 小程序远走高飞了"
                                });
                            },
                            fail: function(t) {
                                wx.hideLoading(), console.log(t), e.setData({
                                    info: "小程序离家出走了稍后再试"
                                });
                            }
                        }) : "87014" == a.errcode ? (wx.hideLoading(), wx.showModal({
                            content: "存在敏感内容，请更换图片",
                            showCancel: !1,
                            confirmText: "明白了"
                        }), e.setData({
                            img: null
                        })) : (wx.hideLoading(), wx.showModal({
                            content: "其他错误，稍后再试",
                            showCancel: !1,
                            confirmText: "明白了"
                        }));
                    }
                });
            }
        });
    },
    onLoad: function() {
        var t = this, a = e.data.openId;
        this.setData({
            openId: a
        }), o.tokenRequest({
            success: function(e) {
                t.setData({
                    token: e.access_token
                });
            }
        });
    }
});